package ace.cmp.id.generator.snowflake.builder;

import ace.cmp.id.generator.api.LongIdGenerator;
import ace.cmp.id.generator.snowflake.impl.SnowflakeImpl;
import ace.cmp.id.generator.snowflake.property.SnowflakeManualProperties;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Caspar
 * @create 2020/12/9
 */
@Slf4j
public class SnowflakeManualBuilder implements SnowflakeBuilder {

  private final SnowflakeManualProperties snowflakeManualProperties;

  public SnowflakeManualBuilder(SnowflakeManualProperties snowflakeManualProperties) {
    this.snowflakeManualProperties = snowflakeManualProperties;
  }

  @Override
  public LongIdGenerator build() {
    Integer dataCenterId = snowflakeManualProperties.getDataCenterId();
    Integer workerId = snowflakeManualProperties.getWorkerId();

    return new SnowflakeImpl(dataCenterId, workerId);
  }
}
